import java.awt.Color;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;

public class Controle extends JPanel implements MouseListener {
	private ArrayList<JButton> botoes = new ArrayList<JButton>();
	static String botaoPressionado;
	
	public Controle() {

		setLayout(null);
		JButton b = new JButton("vermelho");
		b.setName("vermelho");
		b.setBackground(Color.red);

		botoes.add(b);
		b = new JButton("verde");
		b.setName("verde");
		b.setBackground(Color.green);
		botoes.add(b);
		b = new JButton("amarelo");
		b.setName("amarelo");
		b.setBackground(Color.yellow);
		botoes.add(b);
		b = new JButton("azul");
		b.setName("azul");
		b.setBackground(Color.blue);
		botoes.add(b);
		this.setBorder(LineBorder.createBlackLineBorder());
		for (int i = 0; i < botoes.size(); i++) {
			botoes.get(i).setBounds(10 + (i * 30), 50, 30, 30);
			botoes.get(i).addMouseListener(this);
			add(botoes.get(i));
		}
	}

	@Override
	public void mouseClicked(MouseEvent arg0) {
		// TODO Auto-generated method stub
		// if(arg0.getSource() instanceof Midia )
		if (arg0.getSource() instanceof JButton) {
			botaoPressionado = ((JButton) arg0.getSource()).getName();

			
		
		//	System.out.println("pressionei botao " + botaoPressionado);
		}
	}

	@Override
	public void mouseEntered(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub

		botaoPressionado = null;
	}
}
